package com.motherchild.user.service.impl;

import com.motherchild.user.dto.CartItemDTO;
import com.motherchild.user.mapper.CartMapper;
import com.motherchild.user.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {
    @Autowired
    private CartMapper cartMapper;

    @Override
    public List<CartItemDTO> getCartItems(Long userId) {
        return cartMapper.selectCartItemsByUserId(userId);
    }

    @Override
    public void addToCart(CartItemDTO cartItemDTO) {
        cartMapper.insertCartItem(cartItemDTO);
    }

    @Override
    public void removeFromCart(Long productId, Long userId) {
        cartMapper.deleteCartItem(productId, userId);
    }



    @Override
    public void updateCartItem(Long userId, Long productId, Integer quantity) {
        cartMapper.updateCartItem(userId, productId, quantity);
    }
} 